import { commands, Uri, workspace } from 'vscode';
import { CommandConst, GlobalConst } from '../../constants';

/**
 * 打开指定系统的插件清单至工作区
 *
 * @author chitanda
 * @date 2022-12-14 09:12:33
 * @export
 * @class SystemOpenPluginsCommand
 */
export class SystemOpenPluginsCommand {
  constructor() {
    commands.registerCommand(
      CommandConst.SYSTEM.LIST.OPEN_PLUGINS,
      this.execute,
      this,
    );
  }

  protected async execute(sys: Record<string, string>): Promise<void> {
    const id = sys.pssystemid;
    const name = sys.pssystemname;
    workspace.updateWorkspaceFolders(0, 0, {
      uri: Uri.parse(`${GlobalConst.FS_PROTOCOL.SYSTEM}/${id}/`),
      name: `${name}(${id})`,
    });
  }
}
